package com.mvc.security.model;

import javax.persistence.Entity;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import com.mvc.framework.model.CommonAuditableEntity;

@Entity(name = "F_MENU")
public class Menu extends CommonAuditableEntity {
	private static final int PATH_MAX_LENGTH = 512;
	private static final int NAME_MAX_LENGTH = 64;
	private static final int STATUS_MAX_VALUE = 10;
	public static final int MENU_STATUS_ONLINE = 1;
	public static final int MENU_STATUS_OFFLINE = 2;

	public static final String HTTP_LINK_PREFIX = "http://";

	public static final String PORT_SPLIT = ":";

	public static final String ROOT_CONTEXT = "/";
	
	public static final String PATH_SEPARATOR = ROOT_CONTEXT;

	public static final int DEFAULT_HTTP_PORT = 80;

	public static final int ROOT_FOLDER_ID = 0;
	public static final int TYPE_FOLDER = 1;
	public static final int TYPE_MENU = 2;
	public static final int RESOURCE_STAUS_NORMAL = 1;
	public static final int RESOURCE_STAUS_OFFLINE = 2;
	public static final int DISPLAY_POSITION_SYSTEM_MENU = 0;
	public static final int DISPLAY_POSITION_TAB = 1;
	public static final int DISPLAY_POSITION_BOTH = 2;

	public static final Menu ROOT = new Menu();
	static{
		ROOT.setObjectId(0);
		ROOT.setParentId(-1);
		ROOT.setName("ROOT");
		ROOT.setType(TYPE_FOLDER);
	}

	private String url;
	private Integer type;
	private Integer orderId;
	private Integer parentId;
	private Integer serverId;
	@Range(min = 1, max = STATUS_MAX_VALUE)
	private Integer status;
	private String fullUrl;
	@Length(max = PATH_MAX_LENGTH)
	private String path;
	@NotNull
	@Length(max = NAME_MAX_LENGTH)
	private String name;
	private Integer displayPosition;

	public String getUrl() {
    	return url;
    }

	public void setUrl(String url) {
    	this.url = url;
    }

	public Integer getOrderId() {
		return orderId;
	}

	public void setOrderId(Integer orderId) {
		this.orderId = orderId;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Integer getParentId() {
    	return parentId;
    }

	public void setParentId(Integer parentId) {
    	this.parentId = parentId;
    }

	public Integer getServerId() {
    	return serverId;
    }

	public void setServerId(Integer serverId) {
    	this.serverId = serverId;
    }
	public String getPath() {
    	return path;
    }

	public void setPath(String path) {
    	this.path = path;
    }
	@Transient
	public String getFullUrl() {
    	return fullUrl;
    }
	public void setFullUrl(String fullUrl) {
    	this.fullUrl = fullUrl;
    }
	public String getName() {
    	return name;
    }
	public void setName(String name) {
    	this.name = name;
    }
	public Integer getDisplayPosition() {
    	return displayPosition;
    }
	public void setDisplayPosition(Integer displayPosition) {
    	this.displayPosition = displayPosition;
    }
}
